﻿@{
    ViewBag.Title = "主页面";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>后台权限管理系统</title>
    <meta name="Keywords" content="LeoBlog" />
    <meta name="Description" content="LeoBlog" />
    <link href="~/Content/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <link href="~/Content/easyui/themes/color.css" rel="stylesheet" />
    <link href="~/Content/easyui/themes/icon.css" rel="stylesheet" />
    <link href="~/Content/css/main.css" rel="stylesheet" />
    <link href="~/Content/css/fontawesome/css/font-awesome.min.css" rel="stylesheet" />
</head>
<body>
    <!--[if lte IE 7]>
        <div id="errorie"><div>您还在使用老掉牙的IE，正常使用系统前请升级您的浏览器到 IE8以上版本 <a target="_blank" href="http://windows.microsoft.com/zh-cn/internet-explorer/ie-8-worldwide-languages">点击升级</a>&nbsp;&nbsp;强烈建议您更改换浏览器：<a href="http://down.tech.sina.com.cn/content/40975.html" target="_blank">谷歌 Chrome</a></div></div>
    <![endif]-->
    <div id="cc" class="easyui-layout" fit="true">
        @*头部内容*@
        <div data-options="region:'north',split:false" style="height: 85px; background-color: rgba(0, 0, 0, 0.1);">
            <div style="height: 40px; width: 100%; line-height: 40px;">
                <div id="logo" style="float: left; font-size: large; padding: 0 10px;">后台管理系统</div>
                <div class="headerHelp">
                    <ul>
                        <li><i class="fa fa-clock-o"></i>&nbsp;<span id="datetime"></span></li>
                        <li id="loginInfo"><i class="fa fa-info-circle"></i>&nbsp;<a href="javascript:void(0);">你好，@ViewBag.UserName</a></li>
                        <li id="liFavorite"><i class="fa fa-star"></i>&nbsp;<a href="javascript:void(0);">收藏</a></li>
                        <li><i class="fa fa-power-off"></i>&nbsp;<a href="/Login/Logout">退出</a></li>
                    </ul>
                </div>
                <div id="menuInfo" class="easyui-menu" style="width: 120px;">
                    <div>个人信息</div>
                    <div>修改密码</div>
                    <div>退出</div>
                </div>
            </div>
            <div id="headerNav" class="headerNav">
            </div>
        </div>
        @*底部*@
        <div data-options="region:'south',split:false" style="height: 30px; text-align: center; line-height: 28px; font-size: 14px;">
            Copyright © @DateTime.Now.ToString("yyyy") By LeoLcy
        </div>
        @*左边导航栏*@
        <div data-options="region:'west',split:true,title:'功能菜单',headerCls:'leftHeadMenu'" style="width: 200px;">
            <div id="divAccordion" class="easyui-accordion" fit="true">
                @*<div title="Title1" data-options='headerCls:"leftAccordion",selected:true'>
                    <ul class="navlist">
                        <li>
                            <div>
                                <a title="伯乐账号" href="javascript:void(0)" rel="EnterpriseCenter/Ent_Account.aspx?ModuleID=MD0022" ref="MD0022"><span class="nav">伯乐账号</span></a>
                                <i class="fa fa-hand-o-right"></i>
                            </div>
                        </li>
                        <li>
                            <div class="selected">
                                <a title="千里马账号" href="javascript:void(0)" rel="UserCenter/Per_Account.aspx?ModuleID=MD14110001" ref="MD14110001"><span class="nav">千里马账号</span></a>
                            </div>
                        </li>
                    </ul>
                </div>
                <div title="Title2" data-options="iconCls:'icon-reload'">
                    <ul class="navlist">
                        <li>
                            <div>
                                <a title="伯乐账号" href="javascript:void(0)" rel="EnterpriseCenter/Ent_Account.aspx?ModuleID=MD0022" ref="MD0022"><span class="nav">伯乐账号</span></a>
                            </div>
                        </li>
                        <li>
                            <div class="selected">
                                <a title="千里马账号" href="javascript:void(0)" rel="UserCenter/Per_Account.aspx?ModuleID=MD14110001" ref="MD14110001"><span class="nav">千里马账号</span></a>
                            </div>
                        </li>
                    </ul>
                </div>
                <div title="Title3">
                    <ul class="navlist">
                        <li>
                            <div>
                                <a title="伯乐账号" href="javascript:void(0)" rel="EnterpriseCenter/Ent_Account.aspx?ModuleID=MD0022" ref="MD0022"><span class="nav">伯乐账号</span></a>
                                <i class="fa fa-hand-o-right"></i>
                            </div>
                        </li>
                        <li>
                            <div class="selected">
                                <a title="千里马账号" href="javascript:void(0)" rel="UserCenter/Per_Account.aspx?ModuleID=MD14110001" ref="MD14110001"><span class="nav">千里马账号</span></a>
                            </div>
                        </li>
                        <li>
                            <div>
                                <a title="伯乐账号" href="javascript:void(0)" rel="EnterpriseCenter/Ent_Account.aspx?ModuleID=MD0022" ref="MD0022"><span class="nav">伯乐账号</span></a>
                            </div>
                        </li>
                        <li>
                            <div class="selected">
                                <a title="千里马账号" href="javascript:void(0)" rel="UserCenter/Per_Account.aspx?ModuleID=MD14110001" ref="MD14110001"><span class="nav">千里马账号</span></a>
                            </div>
                        </li>
                    </ul>
                </div>*@

            </div>
        </div>
        @*中间内容*@
        <div data-options="region:'center',border:false,split:false">
            <div id="tabs" class="easyui-tabs" fit="true" border="false">
                <div title="欢迎使用" href="/Home/Main">
                </div>
            </div>
        </div>
    </div>
    @* 右鍵菜單*@
    <div id="rightMenu" class="easyui-menu" style="width: 150px;">
        <div id="refresh">刷新</div>
        <div class="menu-sep"></div>
        <div id="close">关闭</div>
        <div id="closeall">全部关闭</div>
        <div id="closeother">除此之外全部关闭</div>
        <div class="menu-sep"></div>
        <div id="closeright">当前页右侧全部关闭</div>
        <div id="closeleft">当前页左侧全部关闭</div>
        <div class="menu-sep"></div>
        <div id="exit">退出</div>
    </div>
    <div>
        <input type="hidden" id="hideModuleID" value="@ViewBag.ModuleID" />
    </div>
    <script src="~/Content/js/jquery-2.2.3.min.js"></script>
    <script src="~/Content/easyui/jquery.easyui.min.js"></script>
    <script>
        $(function () {
            $("#datetime").text(getDateTime());
            setInterval(function () {
                $("#datetime").text(getDateTime());
            }, 1000);

            var moduleID = $("#hideModuleID").val();
            var id = getMenuModule(moduleID,"0");
            //設置默認選中哪一個顶级头部菜單
            var $alist = $("#headerNav ul li a");
            if (id) {
                var length = $alist.size();
                for (var i = 0; i < length; i++) {
                    if ($alist.eq(i).attr("id") == id) {
                        $alist.eq(i).trigger('click');
                    }
                }
            } else {
                $alist.eq(0).trigger('click');
            }
            tabClose();
            tabCloseEven();
        });
        //获取当前时间
        function getDateTime() {
            return new Date().toLocaleString();
        }
        //创建iframe
        function createFrame(url) {
            var s = '<iframe name="iframe_parent" frameborder="0"  style="width:100%;height:99%;overflow:scroll;padding:0px;margin:0px;"  src="' + url + '" ></iframe>';
            return s;
        }

        function addTab(subtitle, url, icon) {
            if (!$('#tabs').tabs('exists', subtitle)) {
                var tabs = $('#tabs').tabs('tabs');
                //只能打开10个tab
                if (tabs.length > 10) {
                    $('#tabs').tabs('close', 1);
                }
                $('#tabs').tabs('add', {
                    width: '100%',
                    height: '100%',
                    title: subtitle,
                    content: createFrame(url),
                    closable: true,
                    icon: icon
                });
            } else {
                //tab已存在的情况
                $('#tabs').tabs('select', subtitle);
                var currentTab = $('#tabs').tabs('getSelected');
                var iframe = $(currentTab.panel('options').content);
                var src = iframe.attr('src');
                $('#tabs').tabs('update', {
                    tab: currentTab,
                    options: {
                        content: createFrame(src)
                    }
                });
            }
            tabClose();
        }

        //在页面中打开新的Tab
        function AddSubTab(title, url, icon) {
            var jq = top.jQuery;
            if (jq('#tabs').tabs('exists', title)) {
                jq('#tabs').tabs('close', title);
            }
            var tabs = jq('#tabs').tabs('tabs');
            if (tabs.length > 10) {
                jq('#tabs').tabs('close', 1);
            }
            jq('#tabs').tabs('add', {
                width: '100%',
                height: '100%',
                title: title,
                content: createFrame(url),
                closable: true,
                icon: icon
            });
        }
        //绑定tab右键事件
        function tabClose() {
            /*双击关闭TAB选项卡*/
            $(".tabs-inner").dblclick(function () {
                var subtitle = $(this).children(".tabs-closable").text();
                $('#tabs').tabs('close', subtitle);
            });
            /*为选项卡绑定右键*/
            $("#tabs").delegate('a', 'contextmenu', function (e) {
                $('#rightMenu').menu('show', {
                    left: e.pageX,
                    top: e.pageY
                });
                var subtitle = $(this).children(".tabs-closable").text();
                $('#tabs').tabs('select', subtitle);
                return false;
            });
        }
        //绑定右键菜单事件
        function tabCloseEven() {
            $('#rightMenu').menu({
                onClick: function (item) {
                    closeTab(item.id);
                }
            });
            return false;
        }
        //右键菜单操作tab
        function closeTab(action) {
            try {
                var $tabs = $('#tabs');
                var alltabs = $tabs.tabs('tabs');
                var currentTab = $tabs.tabs('getSelected');
                var allTabtitle = [];
                $.each(alltabs, function (i, n) {
                    allTabtitle.push($(n).panel('options').title);
                });
                switch (action) {
                    case "refresh":
                        var iframe = $(currentTab.panel('options').content);
                        var src = iframe.attr('src');
                        $tabs.tabs('update', {
                            tab: currentTab,
                            options: {
                                content: createFrame(src)
                            }
                        });
                        break;
                    case "close":
                        //var currtab_title = currentTab.panel('options').title;
                        var tabIndex = $tabs.tabs("getTabIndex", currentTab);
                        $tabs.tabs('close', tabIndex);
                        break;
                    case "closeall":
                        $.each(allTabtitle, function (i, n) {
                            if (n != onlyOpenTitle) {
                                $('#tabs').tabs('close', n);
                            }
                        });
                        break;
                    case "closeother":
                        var currtab_title = currentTab.panel('options').title;
                        $.each(allTabtitle, function (i, n) {
                            if (n != currtab_title && n != onlyOpenTitle) {
                                $('#tabs').tabs('close', n);
                            }
                        });
                        break;
                    case "closeright":
                        var tabIndex = $('#tabs').tabs('getTabIndex', currentTab);

                        if (tabIndex == alltabs.length - 1) {
                            alert('后边没有啦 !');
                            return false;
                        }
                        $.each(allTabtitle, function (i, n) {
                            if (i > tabIndex) {
                                if (n != onlyOpenTitle) {
                                    $('#tabs').tabs('close', n);
                                }
                            }
                        });

                        break;
                    case "closeleft":
                        var tabIndex = $('#tabs').tabs('getTabIndex', currentTab);
                        if (tabIndex == 1) {
                            alert('第一個不能關閉!');
                            return false;
                        }
                        $.each(allTabtitle, function (i, n) {
                            if (i < tabIndex) {
                                if (n != onlyOpenTitle) {
                                    $('#tabs').tabs('close', n);
                                }
                            }
                        });

                        break;
                    case "exit":
                        $('#rightMenu').menu('hide');
                        break;
                }
            }
            catch (e) {
            }
        }
        //moduleID为根节点的parent
        function getMenuModule(moduleID,rootId) {
            var menuModule;//定义获取到的菜单项
            var randomCode = Math.random(1000);
            $.ajax({
                cache: false,
                async: false,
                type: "get",
                url: "/Home/GetTopModules",
                data: { randomCode: randomCode, moduleID: rootId },
                dataType: "json",
                success: function (data) {
                    menuModule = data;
                    var acon = [];
                    acon.push("<ul>");
                    $.each(data, function (i, webObj) {
                        acon.push("<li><a href='javascript:void(0)' title='" + webObj.Module.ModuleDesc
                            + "' id='" + webObj.Module.ModuleId + "' ><i class='" + webObj.Module.IconName + "'></i>&nbsp;&nbsp" + webObj.Module.ModuleName + "</a></li>");
                    });
                    acon.push("</ul>");
                    $("#headerNav").append(acon.join(""));
                },
                error: function (msg) {
                    alert(msg);
                    //window.location.href = '/Login/Index';
                    return;
                }
            });
            //获取传入节点的父节点和父父节点
            var modulePath = SetMenuSequence(menuModule, moduleID);
            var list=[];//list[0] 父父节点 list[1] 父节点 list[2]
            if (modulePath) { list = modulePath.split('-'); }
            
            $(document).on('click', '#headerNav ul li', function () {
                var num = $(this).index();
                $(this).addClass("liHover").siblings().removeClass('liHover');
                var id = $(this).find("a").attr("id"); //$("#headerNav ul li a").eq(num).attr('id');

                $(this).children().addClass('aHover');
                $(this).siblings().children().removeClass('aHover');
                //生成左边菜单,list[0]是为了展示第2层
                GetSysFun(menuModule, id, list[1]);
                //设置默认打开哪个页面，设置选中Accordion中的选项，id为头部的moduleID
                if (list[0] == id) {
                    var alist = $('.navlist li a');
                    var length = alist.size();
                    for (var i = 0; i < length; i++) {
                        if (alist.eq(i).attr("ref") == moduleID) {
                            alist.eq(i).trigger("click");
                        }
                    }
                } else {
                    $('.navlist li a').eq(0).trigger("click");
                }
            });
            var accordionTitles = [];
            //menuModule所有菜单项,moduleID是第一层ID，menuID是第2层ID
            function GetSysFun(menuModule, moduleID, menuID) {
                //每次根据菜单生成Accordion，需要将Accordion清空
                if (accordionTitles.length > 0) {
                    for (var i = 0; i < accordionTitles.length; i++) {
                        $('#divAccordion').accordion('remove', accordionTitles[i]);
                    }
                    //初始化計數
                    accordionTitles = [];
                }

                $.each(menuModule, function (i, Obj) {
                    if (Obj.Module.ModuleId == moduleID) {
                        $.each(Obj.Children, function (j, secondObj) {
                            var moduleName = secondObj.Module.ModuleName;
                            var moduleDesc = secondObj.Module.ModuleDesc;
                            var moduleSysID = secondObj.Module.ModuleId;
                            var iconName = secondObj.Module.IconName;
                            var moduleSysModule = secondObj.Children;//第三层对象
                            //遞歸組成菜單項，傳遞一個moduleID
                            if (moduleSysModule && moduleSysModule.length > 0) {
                                var acon = [];
                                acon.push("<ul id='tt1' class='navlist'> ");
                                $.each(moduleSysModule, function (i, thirdObj) {
                                    eachM = thirdObj.Module;
                                    if (eachM.UrlPara) {
                                        //需要在<span class="nav"></span>里增加图标
                                        acon.push('<li><div><a ref="' + eachM.ModuleId + '" href="javascript:void(0)" rel="'
                                            + eachM.WebUrl + "?ModuleID=" + eachM.ModuleId + eachM.UrlPara + '" title="' + eachM.ModuleDesc
                                            + '" ><span class="nav"><span class="' + eachM.IconName + '"></span>' + eachM.ModuleName
                                            + '</span></a><i class="fa fa-hand-o-right"></i></div> </li>');
                                    }
                                    else {
                                        acon.push('<li><div><a ref="' + eachM.ModuleId + '" href="javascript:void(0)" rel="'
                                            + eachM.WebUrl + "?ModuleID=" + eachM.ModuleId + '" title="' + eachM.ModuleDesc
                                            + '" ><span class="nav"><span class="' + eachM.IconName + '"></span>' + eachM.ModuleName
                                            + '</span></a><i class="fa fa-hand-o-right"></i></div> </li>');
                                    }
                                });
                                acon.push("</ul>");
                            }
                            var content = '';
                            if (acon) { content = acon.join(''); }
                            if (menuID == moduleSysID) {
                                $("#divAccordion").accordion('add', {
                                    title: moduleName,
                                    content: content,
                                    selected: true,
                                    iconCls: iconName
                                });
                            } else {
                                if (j == 0) {
                                    $("#divAccordion").accordion('add', {
                                        title: moduleName,
                                        content: content,
                                        selected: true,
                                        iconCls: iconName
                                    });
                                } else {
                                    $("#divAccordion").accordion('add', {
                                        title: moduleName,
                                        content: content,
                                        selected: false,
                                        iconCls: iconName
                                    });
                                }
                            }
                            accordionTitles.push(moduleName);

                        });
                    }
                });

                $('.navlist li a').click(function () {
                    var tabTitle = $(this).children('.nav').text();
                    var url = $(this).attr("rel");
                    var menuid = $(this).attr("ref");
                    var icon = $(this).find('.fa').attr('class');
                    addTab(tabTitle, url, icon);
                    $('.navlist li div').removeClass("selected");
                    $(this).parent().addClass("selected");
                }).hover(function () {
                    $(this).parent().addClass("hover");
                }, function () {
                    $(this).parent().removeClass("hover");
                });
            }
            //获取传入节点的父节点和父父节点
            function SetMenuSequence(menuModule, moduleId) {
                var path;
                for(var index=0;index<menuModule.length;index++){
                    var obj=menuModule[index].Children;
                    for(var i=0;i<obj.length;i++){
                        var secondObj=obj[i].Children;
                        for(var j=0;j<secondObj.length;j++){
                            var thirdObj = secondObj[j];
                            if (thirdObj.Module.ModuleId == moduleId) {
                                path = thirdObj.Module.ModulePath;
                                break;
                            }
                        }
                    }
                }
                return path;
            }
            //获取传入节点的父节点和父父节点,节点路径。ModulePath为 父父节点-父节点-当前节点
            //递归 有错误
            function getModuleInfo(menuModule, moduleId) {
                for (var i = 0; i < menuModule.length;i++) {
                    console.log(menuModule[i].Module.ModuleId);
                    if (menuModule[i].Module.ModuleId == moduleId) {
                        alert(menuModule[i].Module.ModulePath);
                        return menuModule[i].Module.ModulePath;
                    } else {
                        if (menuModule[i].Children) {
                            if (menuModule[i].Children.length > 0) {
                                return getModuleInfo(menuModule[i].Children, moduleId);
                            }
                        }
                    }
                }
            }
            //返回头部的ID
            return list[0];
        }
    </script>
    @*<script>
            function GetSysModual(moduleID) {
                var randomCode = Math.random(1000);
                $.ajax({
                    cache: false,
                    async: false,
                    type: "post",
                    url: "/Main/GetTopModules",
                    data: { randomCode: randomCode, moduleID: moduleID },
                    dataType: "json",
                    success: function (data) {
                        //alert(data);
                        var acon = "";
                        acon += "<ul>";
                        $.each(data, function (i, webObj) {
                            acon += "<li><a href='javascript:void(0)' title='" + webObj.ModuleDesc + "' id='" + webObj.ModuleID + "' >" + webObj.ModuleName + "</a></li>";
                        });
                        acon += "</ul>";
                        $("#headerNav").append(acon);
                    },
                    error: function (msg) {
                        window.location.href = '/Login/Index';
                        //alert(msg);
                        //alert('系統超時，請重新登錄!');
                    }
                });
                //获取传入节点的父节点和父父节点
                var list = SetMenuSequence(moduleID);
                $(document).on('click', '#headerNav ul li', function () {
                    var num = $(this).index();
                    $(this).addClass("liHover").siblings().removeClass('liHover');
                    var id = $("#headerNav ul li a").eq(num).attr('id');

                    $(this).children().addClass('aHover');
                    $(this).siblings().children().removeClass('aHover');

                    GetSysFun(id, list[0]);
                    //设置默认打开哪个页面
                    if (list[1] == id) {
                        var length = $('.navlist li a').size();
                        for (var i = 0; i < length; i++) {
                            if ($('.navlist li a').eq(i).attr("ref") == moduleID) {
                                $('.navlist li a').eq(i).trigger("click");
                            }
                        }
                    } else {
                        $('.navlist li a').eq(0).trigger("click");
                    }
                });
                return list[1];
            }
            var moduleTitles = "";
            function GetSysFun(moduleID, menuID) {
                var randomCode = Math.random(1000);
                //刪除已經存在的模組
                if (moduleTitles != "") {
                    var titles = moduleTitles.split(",");
                    for (var i = 0; i < titles.length; i++) {
                        if (titles[i] != "")
                            $('#divAccordion').accordion('remove', titles[i]);
                    }
                    //初始化計數
                    moduleTitles = "";
                }
                $.ajax({
                    cache: false,
                    async: false,
                    type: "post",
                    url: "/Main/GetSecondModules",
                    data: { moduleID: moduleID, random: randomCode },
                    dataType: "json",
                    success: function (data) {
                        $.each(data, function (i, webObj) {
                            var moduleName = webObj.ModuleName;
                            var moduleDesc = webObj.ModuleDesc;
                            var moduleSysID = webObj.ModuleID;
                            var moduleSysModule = webObj.Sys_Module;
                            //遞歸組成菜單項，傳遞一個moduleID
                            if (moduleSysModule != null) {
                                var acon = "";
                                acon += "<ul id='tt1' class='navlist'> ";
                                $.each(moduleSysModule, function (i, eachM) {
                                    //alert(eachM.UrlPara);
                                    if (eachM.UrlPara != null && eachM.UrlPara != "") {
                                        acon += '<li><div><a ref="' + eachM.ModuleID + '" href="javascript:void(0)" rel="' + eachM.WebUrl + "?ModuleID=" + eachM.ModuleID + eachM.UrlPara + '" title="' + eachM.ModuleDesc
                                            + '" ><span class="nav">' + eachM.ModuleName + '</span></a></div> </li>';
                                    }
                                    else {
                                        acon += '<li><div><a ref="' + eachM.ModuleID + '" href="javascript:void(0)" rel="' + eachM.WebUrl + "?ModuleID=" + eachM.ModuleID + '" title="' + eachM.ModuleDesc
                                            + '" ><span class="nav">' + eachM.ModuleName + '</span></a></div> </li>';
                                    }
                                    //第三層
                                    //if (eachM.Sys_Module != null) {
                                    //    acon += "<ul>";
                                    //    $.each(moduleSysModule, function (i, eachM) {
                                    //        acon += '<li><div><a ref="' + eachM.ModuleID + '" href="javascript:void(0)" rel="' + eachM.WebUrl + '" title="' + eachM.ModuleDesc
                                    //    + '" ><span class="icon" >&nbsp;</span><span class="nav">' + eachM.ModuleName + '</span></a></div> </li>';
                                    //    });
                                    //    acon += "</ul>";
                                    //}
                                });
                                acon += "</ul>";
                            }
                            if (menuID == moduleSysID) {
                                $("#divAccordion").accordion('add', {
                                    title: moduleName,
                                    content: acon,
                                    selected: true
                                });
                            } else {
                                if (i == 0) {
                                    $("#divAccordion").accordion('add', {
                                        title: moduleName,
                                        content: acon,
                                        selected: true
                                    });
                                } else {
                                    $("#divAccordion").accordion('add', {
                                        title: moduleName,
                                        content: acon,
                                        selected: false
                                    });
                                }
                            }
                            moduleTitles = moduleTitles + moduleName + ",";
                        });
                    },
                    error: function (msg) {
                        alert(msg.responseText);
                    }
                });

                $('.navlist li a').click(function () {
                    var tabTitle = $(this).children('.nav').text();
                    var url = $(this).attr("rel");
                    var menuid = $(this).attr("ref");
                    var icon = $(this).find('.icon').attr('class');
                    addTab(tabTitle, url, icon);
                    $('.navlist li div').removeClass("selected");
                    $(this).parent().addClass("selected");
                }).hover(function () {
                    $(this).parent().addClass("hover");
                }, function () {
                    $(this).parent().removeClass("hover");
                });
            }
        //获取传入节点的父节点和父父节点
            function SetMenuSequence(id) {
                var list;
                $.ajax({
                    type: "post",
                    async: false,
                    url: "/Main/GetModules",
                    data: { moduleID: id }, //數據格式要正確
                    dataType: "text",
                    //contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        //var res = data.d;
                        list = data.split(",");
                    },
                    error: function (msg) {
                        window.location.href = '/Login/Index';
                        alert('系統超時，請重新登錄!');
                    }
                });
                return list;
            }



            //function SubTabClose() {
            //    var jq = top.jQuery;
            //    /*双击关闭TAB选项卡*/
            //    $(".tabs-inner").dblclick(function () {
            //        var subtitle = jq(this).children(".tabs-closable").text();
            //        jq('#tabs').tabs('close', subtitle);
            //    })
            //    /*为选项卡绑定右键*/
            //    $("#tabs").delegate('a', 'contextmenu', function (e) {
            //        jq('#mm').menu('show', {
            //            left: e.pageX,
            //            top: e.pageY
            //        });

            //        var subtitle = jq(this).children(".tabs-closable").text();

            //        //jq('#mm').data("currtab", subtitle);
            //        jq('#tabs').tabs('select', subtitle);
            //        return false;
            //    });
            //}


            //添加收藏
            function AddFavorite(sURL, sTitle) {
                try {
                    window.external.addFavorite(sURL, sTitle);
                }
                catch (e) {
                    try {
                        window.sidebar.addPanel(sTitle, sURL, "");
                    }
                    catch (e) {
                        alert("加入收藏失败，请使用Ctrl+D进行添加");
                    }
                }
            }
            function find(menuid) {
                var obj = null;
                $.each(_menus.menus, function (i, n) {
                    $.each(n.menus, function (j, o) {
                        if (o.menuid == menuid) {
                            obj = o;
                        }
                    });
                });
                return obj;
            }
            //弹出信息窗口 title:标题 msgString:提示信息 msgType:信息类型 [error,info,question,warning]
            function msgShow(title, msgString, msgType) {
                $.messager.alert(title, msgString, msgType);
            }
            ///打開關於的對話框
            function openAbout() {
                $("#dialogHelp").dialog({
                    title: '幫助',
                    width: 400,
                    height: 300,
                    iconCls: 'icon-help',
                    modal: true,
                    closed: false//默認dialog是打開的，要先關閉
                });
            }

            //對話框最大化
            function WindowMaximization() {
                window.moveTo(0, 0);
                window.resizeTo(screen.availWidth, screen.availHeight);
                window.outerWidth = screen.availWidth;
                window.outerHeight = screen.availHeight;
            }

            function changeDateFormat(cellval) {
                if (cellval.indexOf("/Date(") >= 0) {
                    var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
                    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                    var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                    var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                    var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
                    return date.getFullYear() + "/" + month + "/" + currentDate + " " + hour + ":" + minute + ":" + second;
                } else { return cellval; }
            }
        </script>*@
</body>
</html>

